/*
 *   AS IS License
 * ==Naive Coders==
 */
package org.naive.metawatch.converter.cap;

import org.naive.metawatch.converter.parser.FieldSize;
import org.naive.metawatch.converter.parser.Parsed;
import org.naive.metawatch.converter.parser.ParsedInt;
import org.naive.metawatch.converter.parser.cap.CapParseable;

/**
 *
 * @author gbu.000
 */
public class CapFieldDescriptorInfo extends CapParseable {
    @ParsedInt(FieldSize.BYTE)
    public byte token;
    @ParsedInt(FieldSize.BYTE)
    public byte access_flags;
// if not static
//    is to be interpreted as
//    @Parsed(CapClassRef.class)
//    public CapClassRef classRef;
//    public byte class_token;
    @Parsed(CapStaticMemberRef.class)
    public CapStaticMemberRef staticRef;
    
    @ParsedInt(FieldSize.SHORT)
    public short primitiveOrReferenceType;

    public boolean isPublic() {
        return (access_flags & 0x01) != 0;
    }

    public boolean isPrivate() {
        return (access_flags & 0x02) != 0;
    }

    public boolean isProtected() {
        return (access_flags & 0x04) != 0;
    }

    public boolean isStatic() {
        return (access_flags & 0x08) != 0;
    }

    public boolean isFinal() {
        return (access_flags & 0x10) != 0;
    }
    
     public boolean isInternalClass() {
        return (staticRef.package_token & 0x1) == 0;
    }
    
     public byte getExternalPackageToken() {
        return staticRef.package_token;
    }

    public byte getExternalClassToken() {
        return staticRef.class_token;
    }
}
